﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using System.Web.UI;
using NENAData.LINQ;
using NENAData.NENAProvinces;

namespace PayPal
{
    public partial class NENACart : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (! IsPostBack)
            BindAffiliates();

        }

        public void BindAffiliates()
        {
            NENAAffiliate x = new NENAAffiliate();

            ddl_Affiliate.DataSource = x.GetAffiliates_AllActive();
            ddl_Affiliate.DataTextField = "Province";
            ddl_Affiliate.DataValueField = "Affiliate_Id";
            ddl_Affiliate.DataBind();
        }

        protected void btn_AJAX_Click(object sender, EventArgs e)
        {
            SetAffiliateFees();
        }

        public void SetAffiliateFees()
        {
            try
            {

                NENAAffiliate x = new NENAAffiliate();
                Affiliate oAffiliate;

                oAffiliate = x.GetAffiliate_byAffiliateID(Convert.ToInt32(ddl_Affiliate.SelectedValue));
                
                //AffiliateFee.Text = listAffilates.ToString();
                Session["payment_amt"] = String.Format("{0:00.00}", oAffiliate.Membership_Fee);
                AffiliateFee.Text = Session["payment_amt"].ToString() ;
                imgPayPal.Visible = true;
                //Response.Write("<br />order total: " + Session["payment_amt"]);
            }
            catch (Exception ex)
            {
                Response.Write(ex.InnerException);
            }
        }

        protected void ddl_Affiliate_SelectedIndexChanged(object sender, EventArgs e)
        {
            SetAffiliateFees();
        }

    }
}
